<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="../../../inc/conn.asp"-->
<!--#include file="../common/u.asp"-->
<%links="order"



'分页-------------------------------------------------------
set Rs=server.CreateObject("ADODB.RecordSet")
sql="select count(sortid) from (Select ROW_NUMBER() OVER (order by id desc) as sortid,* From inquiry) as TempTable where 1=1 and uid='"&uid&"'"
Pager_Pagesize=10 '每页记录数
Rs.open sql,conn,1,1
Pager_TotalRecord=Rs(0) '总记录数
Rs.close
Pager_PageCount=int((Pager_TotalRecord/Pager_Pagesize)+0.99999) '计算总页数
CurrentPage=Request("page") '当前页
if CurrentPage=0 then CurrentPage=1
'如果不为数字则直接设置页码为1
if isnumeric(CurrentPage)=False Or CurrentPage="" then
	CurrentPage=1
'如果当前页数大于总页数，则直接设置页码为1
elseif  Clng(CurrentPage)>Pager_PageCount then
	CurrentPage=1
end if
Fieldsname=" [id],[Uid],[Pic],[Title],[url],[Qty],[Content],[Price],[Falg],[Addtime],sortid"
orderBy=" Order by sortid asc"
'拆分SQL语句，必须是select开头，有唯一标识的列
if instr("select",sql)<>-1 then
	if CurrentPage = 1 then
		sql = replace(sql,"select count(sortid)"," select  top " & Pager_Pagesize  & Fieldsname)
	else  
		sql = replace(sql,"select count(sortid)"," select  top " & Pager_Pagesize   & Fieldsname) & " and sortid >(select max(sortid) from (" & replace(sql,"select count(sortid)"," select  top " & Pager_Pagesize * (CurrentPage - 1)  & Fieldsname) & orderBy & ") AA)"
	end if
end if
sql = sql & orderBy
Rs.open sql,conn,1,1
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>代购订单</title>
<link href="favicon.ico" rel="shortcut icon" type="image/x-icon"/>
<link rel="stylesheet" type="text/css" href="/css/style.css" />
<script type="text/javascript" src="/js/jquery.min.js"></script>
<script type="text/javascript" src="/js/jquery.tabs.js"></script>
<script type="text/javascript">
//$(function(){
//	$('.reg_s_1').Tabs({
//		event:'click'
//	});
//});	
</script>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var checkflag = "false";
function checkall(field) {
if (checkflag == "false") {
for (i = 0; i < field.length; i++) {
field[i].checked = true;}
checkflag = "true";}
else {
for (i = 0; i < field.length; i++) {
field[i].checked = false; }
checkflag = "false";	}
}
//end-->
</script>
</head>
<body>

<!--#include file="../../common/top.asp"-->







<div class="fullwidth">
	<div class="place ">
		<a href="/">首页</a> &gt; <a href="/user">会员中心</a> &gt; 代购订单
	</div>
</div>
<!--main-->
<div class="fullwidth bg1">
	<div class="main">
		
		
        <!--#include file="../common/left.asp"-->
        
        
        
		
		<div class="right_show f_r">
			
			<div class="title_4">
				<h2>代购订单</h2><div></div>
			</div>
			<div class="reg_box reg_s_1 account order_tab">
				<ul class="tab_menu">
					<li><a href="/user/order">所有订单</a></li>
					<li class="current"><a href="/user/order/inquiry">询价中</a></li>
					<li><a href="/user/order?typeid=0">待付款订单</a></li>
					<li><a href="/user/order?typeid=1">已付款订单</a></li>
				</ul>
				<div class="tab_box">
					
					<div>
						<div class="clear20"></div>
						<div class="clear20"></div>
						<div class="clear20"></div>
						
                        <form name="formreg" method="post" action="" onSubmit="return myjobchk();">
                        <table class="stable stable_1 stable_2 stable_3">
							<tr>
							  <th width="50"> <input type="checkbox" name="checkbox2" onClick="javascript:checkall(this.form);" /> 全选</th>
								<th>商品</th>
								<th>备注</th>
								<th>报价</th>
								<th>购买数量</th>				
								<th>状态</th>				
							</tr>
                            
                            
                            <%do while not Rs.eof%>
							<tr>
								<td><%if rs("falg")=true then%><input type="checkbox" name="checkbox" value="<%=rs("id")%>"/><%end if%></td>
								<td style="word-wrap:break-word; width:80px; line-height:18px; padding-bottom:8px; padding-top:8px; padding-left:30px; text-align:left;">
									
                                    <%if rs("pic")<>"" then response.Write "<img src='"&rs("pic")&"' width='100' height='100'>"%>
									<%if rs("title")<>"" then response.Write "<br>"&rs("title")%>
									<%if rs("url")<>"" then response.Write "<br>"&rs("url")%>
                                    
								</td>
								<td style="word-wrap:break-word; width:200px; line-height:18px; padding-bottom:8px; padding-top:8px; padding-left:30px; text-align:left"><%=rs("content")%></td>
								<td><%if rs("price")="0" then response.Write "无" else response.Write rs("price")&"日元"%></td>
								<td><%=rs("qty")%></td>
								<td><%if rs("falg")=true then response.Write "已报价" else response.Write "等待报价"%></td>
							</tr>
                            <%
							Rs.movenext
							loop
							Rs.close
							Set Rs=nothing
							%>
                            
                            
							
							
						</table>
				    <div class="clear20"></div>
                   
                   
                   <div class="btn text_right">
				<a href="javascript:formreg.action='?del=yes';formreg.submit()" class="btn_13">删除</a>
				<a href="javascript:formreg.action='?cart=yes';formreg.submit()" class="btn_14">加入购物车</a>
				<input type="hidden" name="t" value="y" />
            </div>
                   
                    </form>
						<div class="clear20"></div>
					</div>
					
					<div class="page">
							<%
							if CurrentPage<=1 then
							pageview="<a><</a>"
							else
							pageview="<a href='/user/order/inquiry?page="&CurrentPage-1&"'><</a>"
							end if
							for tp = -10 to 9
							if Pager_PageCount>=tp+page and tp+page=>1  then 
							if trim(tp+page)=trim(request("page")) then
							pageview=pageview+"<a class='cur_page'>"&tp+page&"</a>"
							else
							pageview=pageview+"<a href='/user/order/inquiry?page="&tp+page&"'>"&tp+page&"</a>"
							end if
							end if
							next
							if Pager_PageCount<CurrentPage+1 then
							pageview=pageview+"<a>></a>"
							else
							pageview=pageview+"<a href='/user/order/inquiry?page="&CurrentPage+1&"'>></a>"
							end if
							response.Write pageview
							%>
						</div>
					
					
				</div>
				<div class="clear20"></div>
				<div class="clear20"></div>
			</div>	
			
		</div>
		
		
	</div>
</div>

<div class="clear"></div>



<!--#include file="../../common/footer.asp"-->




</body>
</html>
<%
'加入购物车
if request.QueryString("cart")="yes" then
checkbox=request.Form("checkbox")
if checkbox="" then
response.write"<script>alert('请选择商品');</script>"
response.write"<script>window.history.back(-1);</script>"
response.end
end if

set rsnew=server.CreateObject("adodb.recordset")
sql="select * from inquiry where id in("&checkbox&")"
rsnew.open sql,conn,1,3
if not rsnew.eof then
do while not rsnew.eof 

      set rsx=server.createobject("adodb.recordset")
	  sql="select * from cart"
	  rsx.open sql,conn,1,3
	  rsx.addnew
	  rsx("sid")=rsnew("SourceID")
	  rsx("qty")=rsnew("qty")
	  rsx("content")=rsnew("content")
	  rsx("uid")=uid
	  rsx.update
	  rsx.close
	  set rsx=nothing

rsnew.movenext
loop
rsnew.close
set rsnew=nothing
end if
'询价单删除
conn.execute("delete from inquiry where id in("&checkbox&")")
response.Redirect "/cart"
end if




'删除
if request.QueryString("del")="yes" then
  checkbox=request.Form("checkbox")
  
  if checkbox="" then
  response.write"<script>alert('请选择商品');</script>"
  response.write"<script>window.history.back(-1);</script>"
  response.end
  end if
  
  conn.execute("delete from inquiry where id in("&checkbox&")")
  
  response.Redirect "/user/order/inquiry"
end if
%>